package org.nf.api;

import org.nf.partner.model.Partner;
import org.nf.partner.service.PartnerService;
import org.nf.partner.service.impl.PartnerServiceImpl;
import org.nf.product.model.Product;
import org.nf.product.vo.PageVO;
import org.nf.web.annotation.Model;
import org.nf.web.annotation.RequestMapping;
import org.nf.web.annotation.RequestParam;
import org.nf.web.servlet.View;
import org.nf.web.servlet.view.JsonView;

import javax.servlet.http.HttpSession;
import java.util.List;

public class PartnerController extends BaseController{
    private PartnerService service = new PartnerServiceImpl();

    /**
     * 查询合作商
     */
    @RequestMapping("/listPartner")
    public View listPartner(@Model Partner partner, HttpSession session){
        List<Partner> partners = service.listPartner(partner);
        session.setAttribute("partner",partners);
        return new JsonView(success("111"));
    }
    /**
     *  通过名称查询合作商
     */
    @RequestMapping("/getPartner")
    public  View getPartner(@RequestParam("partnerName")String partnerName){
        List<Partner> partner = service.selectPartnerName(partnerName);
        return new JsonView(success(partner));
    }

    /**
     * 通过分页查询
     */
    @RequestMapping("/listPartnerPaging")
    public View lisPartnerPaging(@RequestParam("page")int page,@RequestParam("limit")int limit){
        PageVO<List<Partner>>listPageVO=service.listPartnerPage(page,limit);
        return new JsonView(success(listPageVO));
    }
}
